/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.lis.model;

import com.cxhd.lis.util.DateUtil;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Model;
import java.util.List;

/**
 *
 * @author 52461
 */
public class RoleModel extends Model<RoleModel> {

    public int saveRole(Controller con) {
        int pk;
        if (con.getPara("pk") != null) {
            findById(con.getPara("pk")).set("name", con.getPara("name"))
                    .set("description", con.getPara("description"))
                    .set("createtime", DateUtil.getDateEN()).update();
            pk = con.getParaToInt("pk");
        } else {
            set("name", con.getPara("name"))
                    .set("description", con.getPara("description"))
                    .set("createtime", DateUtil.getDateEN())
                    .save();
            pk = getInt("pk");
        }
        return pk;
    }

    public void deleteRole(String pk) {
        deleteById(pk);
    }

    public List<RoleModel> getRole() {

        return find("select * from lis_system_role");
    }

}
